

<div id='index_main'>
	<h1 style='text-align:center;color:red'>总览审核</h1>

	<div id='indexMain'>

		<div id='indexMain_list'>
			<div style='width:80%;border:0px solid;margin:15px auto;display:flex'>
				<span style='width:200px;border:0px solid;text-align:right;overflow:hidden;white-space: nowrap'>
					顶号国协佃螺蛳粉aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
				</span>
				<span style='flex:1;text-align:center'>
					<button>查看</button>
				</span>
			</div>
		</div>

		<div id='fpage' style='text-align:center;margin:50px auto'></div>
	</div>


	<div id='areaCheck' style='display:none'>
		<div style='margin:50px auto;width:60%'>
			<div style='text-align:center'><h2 id='item_title'>标题</h2></div>
			<div style='margin:30px auto' id='item_content'></div>
			<div style='margin:30px auto'>类　别：<span id='item_type'></span></div>
			<div style='margin:30px auto'>联系人：<span id='item_concat'></span></div>
			<div style='margin:30px auto'>电　话：<span id='item_phone'></span></div>

			<div style='text-align:center'>
				<button onclick='_agree(2)'>通过</button>　
				<button onclick='_agree(3)'>不通过</button>　
				<button onclick='_checkBack()'>返回</button>
			</div>
		</div>
	</div>

	<span style='position:fixed;top:8px;right:110px;cursor:pointer;color:#1a2' onclick='_jumpMain2()'>区域审核</span>
</div>
<script>
var mainPLength = 5;	//每页显示条数
var pNow = 1;	//当前页
var pMax = 2;	//临时最大页

var data = [];	//待审核信息列表容器

var cityData;	//城市信息列表容器

var agreeTime=0;	//审核信息等待时间累计








//审核信息
function _agree(val){
	Notice('');
	Notice('处理中......');
	Ajax({type:'agree','cityCode':sessionStorage.checkCityCode,'id':sessionStorage.checkId,'val':val},function(res){
		C(res);		//若返回false ，可能是请求超时
		if(res == 'wait'){
			agreeTime += 1000;
			var sil = setTimeout(function(){
				if(agreeTime > 5000){
					agreeTime = 0;
					Notice('');
					A('服务器繁忙，稍候再试！');
				}else{
					_agree(val);
				}
			},1000);
		}else if(res == 'ok'){
			Notice('');
			A('操作成功！');
			location.reload();
		}else{
			Notice('');
			A('操作异常！');
		}
	},'interface.php');
}

_init();

function _look(cityCode,id){
	$("#indexMain").hide();
	$("#areaCheck").show();
	sessionStorage.checkCityCode = cityCode;
	sessionStorage.checkId = id;

	_getCityDataList(sessionStorage.checkCityCode,function(){
		var inStat = 0;
		if(cityData){
			for(var i=0;i<cityData.list.length;i++){
				if(cityData.list[i][0] == id){
					inStat = 1;
					$('#item_title').text(cityData.list[i][1]);
					$('#item_content').text(cityData.list[i][2]);
					switch(cityData.list[i][5]){
						case 1:case '1':var tmpStat='房产信息';break;
						case 2:case '2':var tmpStat='二手车';break;
						case 3:case '3':var tmpStat='闲置物品';break;
						case 4:case '4':var tmpStat='招聘求职';break;
						case 5:case '5':var tmpStat='失物招领';break;
						case 6:case '6':var tmpStat='其它';break;
					}
					$('#item_type').text(tmpStat);
					$('#item_concat').text(cityData.list[i][3]);
					$('#item_phone').text(cityData.list[i][4]);
				}
			}
		}
		//若城市信息中不存在当前信息则删除审核列表中的项
		if(inStat == 0){
			var data = {
				type:'removecheckInfo',
				id:id,
				cityCode:cityCode
			}
			Ajax(data,function(res){
				location.reload();
			},'./interface.php');
		}
	})
}




function _checkBack(){
	$("#indexMain").show();
	$("#areaCheck").hide();
}




function _init(){
	_getCheckDataList(function(){
		parseData();
	})
}



//获取待审核的信息列表
function _getCheckDataList(fun,type){
	if(data.length < 1){
		Ajax({},function(res){
		 	if(/^\[\[.*\]\]$/.test(res)){
				if(type)C('checkData from after');
		 		data = JSON.parse(res);
		 	}
		 	if(fun) fun();
		},'./checkInfoList');
	}else{
		if(type)C('checkData from data');
		if(fun) fun();
	}
}





function parseData(){
	if(data && typeof(data) == 'object' && data.length > 0){
		var str = '';
		var start = (pNow - 1) * mainPLength;
		var end = start + mainPLength < data.length?start + mainPLength:data.length;
		if(start + mainPLength < data.length){
			var end = start + mainPLength
			pMax = pNow + 1;
		}else{
			var end = data.length;
			pMax = pNow;
		}
		for(var i=start;i<end;i++){
			str += "<div style='width:80%;border:0px solid;margin:15px auto;display:flex'>";
				str += "<span style='width:200px;border:0px solid;text-align:center;overflow:hidden;white-space: nowrap'>";
					str += data[i][2];
				str += "</span>";
				str += "<span style='flex:1;text-align:center'>";
					str += "<button onclick=_look("+data[i][0]+",'"+data[i][1]+"')>查看</button>";
				str += "</span>";
			str += "</div>";
		}
		$('#indexMain_list').html(str);

		Fpage(pNow,pMax,function(p){
			pNow = p;
			//pMax = p+1;
			_init();
		},1,1,'#fpage')	
	}else{
		$('#indexMain').html('<h2 style="color:#a1c;margin:50px;text-align:center">暂无数据</h2>');
	}
}


</script>
